import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-09-02
 * Time: 11:30
 */
public class test_5 {

    //求数中有几个2
    public static int getnumber(int n) {
        if (n < 10) {
            return n == 2 ? 1 : 0;
        }
        int tmp = n % 10;
        return (tmp == 2 ? 1 : 0) + getnumber(n / 10);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = in.nextInt();
            int m = 0;
            for (int i = a; i <= b; i++) {
                m += getnumber(i);
            }
            System.out.println(m);
        }
    }
}
